function async1 () {
    return new Promise(function (resolve, reject) {
        console.log('async1 start');
        async2().then(function () {
            console.log('aysnc2 then 1');
            resolve();
        }).then(function () {
            console.log('aysnc2 then 2');
        });
    });
}

function async2 () {
    console.log('async2');
    return Promise.resolve();
}

console.log('script start');

setTimeout(function () {
    console.log('setTimeout');
}, 0);

async1().then(function () {
    console.log('aysnc1 then');
});

setTimeout(function () {
    console.log('setTimeout2');
}, 0);

new Promise(function (resolve) {
    console.log('promise1-1');
    setTimeout(function () {
        console.log('setTimeout3');
        resolve();
    }, 0);
}).then(function () {
    console.log('promise1-2');
}).then(function () {
    console.log('promise1-3');
}).then(function () {
    console.log('promise1-4');
});

new Promise(function (resolve) {
    console.log('promise2-1');
    resolve();
}).then(function () {
    console.log('promise2-2');
}).then(function () {
    console.log('promise2-3');
}).then(function () {
    console.log('promise2-4');
});

console.log('script end');
